package com.kugou.miniapp.utils;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;


@Configuration
public class Schedule {
    Logger log = LoggerFactory.getLogger(Schedule.class);
    @Scheduled(fixedRate=10000)
    private void configureTasks() {
//        log.debug("执行静态定时任务时间（保持心跳）: " + LocalDateTime.now());
//        System.out.println("执行静态定时任务时间（保持心跳）: " + LocalDateTime.now());
        //执行定时任务， 保持心跳
        if (GlobalSocket.socket_list != null && GlobalSocket.socket_list.size() > 0){
            for (GlobalSocket socket: GlobalSocket.socket_list){
                socket.session.getAsyncRemote().sendText("心跳");
            }
        }
        if (MatchSocket.socket_list != null &&MatchSocket.socket_list.size() > 0){
            for (MatchSocket socket: MatchSocket.socket_list){
                socket.session.getAsyncRemote().sendText("心跳");
            }
        }
    }

}
